package com.gitee.hioove.io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

public class FileOperate {
    public static void main(String[] args) throws IOException {
        String a = "ASDFGHJKL";
//        try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File("xxxxxxxxxxx.txt"), true))) {
//            bos.write(a.getBytes(StandardCharsets.UTF_8));
//        }
        byte[] str = new byte[1];
        List<String> result = new ArrayList<>();
        try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File("xxxxxxxxxxx.txt")))) {
            while (bis.read(str) != -1) {
                result.add(new String(str, StandardCharsets.UTF_8));
            }
        }
        System.out.println(result);
        try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File("xxxxxxxxxxx.txt"), true))) {
            bos.write(a.getBytes(StandardCharsets.UTF_8));
        }
        byte[] str0 = new byte[1];
        List<String> result0 = new ArrayList<>();
        try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File("xxxxxxxxxxx.txt")))) {
            while (bis.read(str0) != -1) {
                result.add(new String(str0, StandardCharsets.UTF_8));
            }
        }
        System.out.println(result0);
    }
}
